package br.poli.ecomp.tcc.stimultimidia.view.components
{
	import br.poli.ecomp.tcc.stimultimidia.event.TelaLoginEvent;
	import br.poli.ecomp.tcc.stimultimidia.model.vo.UsuarioVO;
	
	import flash.events.MouseEvent;

	public class TelaLogin extends TelaLoginSWC
	{
		public function TelaLogin()
		{
			super();
			
			this.btCadastrar.addEventListener(MouseEvent.CLICK, onCadastrar);
			this.btLogar.addEventListener(MouseEvent.CLICK, onLogar);
			this.btLogar.buttonMode = true;
		}
		
		private function onCadastrar(e:MouseEvent):void
		{
			var evt:TelaLoginEvent = new TelaLoginEvent( TelaLoginEvent.SIGNUP  );
			this.dispatchEvent( evt );
		}
		
		
		private function onLogar(e:MouseEvent):void
		{
			var user:UsuarioVO = new UsuarioVO();
			user.login = this.campoLogin.text;
			user.senha = this.campoSenha.text;
			
			var evt:TelaLoginEvent = new TelaLoginEvent( TelaLoginEvent.LOGIN ,user );
			this.dispatchEvent( evt );
			
		}
		
	}
}